<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="债务人姓名(手机号)" prop="debtorName">
        <el-input
          v-model="queryParams.debtorName"
          placeholder="请输入债务人姓名(手机号)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="原债权方姓名（手机号）" prop="creditorName">
        <el-input
          v-model="queryParams.creditorName"
          placeholder="请输入原债权方姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      
      <el-form-item label="欠款类型" prop="debtType">
        <el-select v-model="queryParams.debtType" placeholder="请选择欠款类型" clearable>
          <el-option
            v-for="dict in dict.type.qklx1"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="收购日期" prop="purchaseDate">
        <el-date-picker
          v-model="queryParams.purchaseDate"
          type="date"
          placeholder="请选择收购日期"
          value-format="yyyy-MM-dd"
          clearable>
        </el-date-picker>
      </el-form-item>
      <el-form-item label="当前步骤" prop="currentStatus">
        <el-select v-model="queryParams.currentStatus" placeholder="请选择当前步骤" clearable>
          <el-option
            v-for="dict in dict.type.dqbz1"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:information:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:information:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:information:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:information:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="informationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="客户编号" align="center" prop="id">
        <template slot-scope="scope">
          {{ formatCustomerId(scope.row.id) }}
        </template>
      </el-table-column>
      <el-table-column label="债务人姓名(手机号)" align="center" prop="debtorName" />
      <el-table-column label="金额" align="center" prop="amount" />
      <el-table-column label="欠款类型" align="center" prop="debtType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.qklx1" :value="scope.row.debtType"/>
        </template>
      </el-table-column>
      <el-table-column label="收购日期" align="center" prop="purchaseDate" width="100" />
      <el-table-column label="当前步骤" align="center" prop="currentStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.dqbz1" :value="scope.row.currentStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="跟进情况" align="center" prop="followUpInfo" />
      
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:information:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:information:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改债权转让对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="债务人姓名（手机号）" prop="debtorName">
              <el-input v-model="form.debtorName" placeholder="请输入债务人姓名(手机号)" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="债务人身份证号" prop="debtorIdCard">
              <el-input v-model="form.debtorIdCard" placeholder="请输入债务人身份证号" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="原债权方姓名（手机号）" prop="creditorName">
              <el-input v-model="form.creditorName" placeholder="请输入原债权方姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原债权方身份证" prop="creditorIdCard">
              <el-input v-model="form.creditorIdCard" placeholder="请输入原债权方身份证号" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="金额" prop="amount">
              <el-input v-model="form.amount" placeholder="请输入金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="欠款类型" prop="debtType">
              <el-select v-model="form.debtType" placeholder="请选择欠款类型" style="width: 100%">
                <el-option
                  v-for="dict in dict.type.qklx1"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="收购日期" prop="purchaseDate">
              <el-date-picker
                v-model="form.purchaseDate"
                type="date"
                placeholder="请选择收购日期"
                style="width: 100%"
                value-format="yyyy-MM-dd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="当前步骤" prop="currentStatus">
              <el-select v-model="form.currentStatus" placeholder="请选择当前步骤" style="width: 100%">
                <el-option
                  v-for="dict in dict.type.dqbz1"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="跟进情况" prop="followUpInfo">
              <el-input v-model="form.followUpInfo" type="textarea" :rows="3" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="文件" prop="fileInfo">
              <el-upload
                class="upload-demo"
                :action="upload.url"
                :headers="upload.headers"
                :on-success="handleUploadSuccess"
                :on-error="handleUploadError"
                :on-remove="handleFileRemove"
                :before-upload="handleBeforeUpload"
                :file-list="fileList"
                multiple>
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">文件大小不超过500MB</div>
              </el-upload>
              <div v-if="form.fileInfo" class="existing-files">
                <div v-for="(file, index) in parsedFileList" :key="index" class="file-item">
                  <span class="file-name">{{ file.name }}</span>
                  <div class="file-actions">
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-download"
                      @click="handleDownload(file)"
                    >下载</el-button>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-delete"
                      @click="handleFileDelete(index)"
                    >删除</el-button>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" :loading="loading">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInformation, getInformation, delInformation, addInformation, updateInformation } from "@/api/system/information";
import { getToken } from "@/utils/auth";
import Cookies from 'js-cookie';

export default {
  name: "Information",
  dicts: ['dqbz1', 'qklx1'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 债权转让表格数据
      informationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        debtorName: null,
        debtorIdCard: null,
        creditorName: null,
        creditorIdCard: null,
        amount: null,
        debtType: null,
        purchaseDate: null,
        currentStatus: null,
        followUpInfo: null,
        fileInfo: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        debtorName: [
          { required: true, message: "债务人姓名(手机号)不能为空", trigger: "blur" }
        ],
        
      },
      // 上传参数
      upload: {
        // 上传地址
        url: process.env.VUE_APP_BASE_API + "/system/information/upload",
        // 请求头部
        headers: { Authorization: "Bearer " + getToken() }
      },
      // 文件列表
      fileList: [],
      parsedFileList: [], // 用于存储已解析的文件列表
      todayIdMap: null,
      maxSequence: null,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 添加一个方法来获取当前用户名称
    getCurrentUserName() {
      // 1. 从store的name字段获取用户名 (实际存储的是userName)
      if (this.$store.state.user && this.$store.state.user.name) {
        return this.$store.state.user.name;
      }
      
      // 2. 从cookie中获取登录账号信息
      try {
        const userName = Cookies.get("username");
        if (userName) {
          return userName;
        }
      } catch (e) {
        console.error('无法从cookie获取用户名:', e);
      }
      
      // 3. 尝试从localStorage或sessionStorage获取
      try {
        // 尝试获取用户信息
        const userStr = localStorage.getItem('userInfo') || 
                       sessionStorage.getItem('userInfo') || 
                       localStorage.getItem('user') || 
                       sessionStorage.getItem('user');
        
        if (userStr) {
          const userData = JSON.parse(userStr);
          if (userData.userName) {
            return userData.userName;
          } else if (userData.username) {
            return userData.username;
          } else if (userData.name) {
            return userData.name;
          }
        }
      } catch (e) {
        console.error('无法从存储中获取用户名:', e);
      }
      
      // 4. 最后尝试从getters获取
      if (this.$store.getters.user && this.$store.getters.user.name) {
        return this.$store.getters.user.name;
      }
      
      // 5. 如果无法获取用户名，尝试使用getToken去检查是否已登录
      if (getToken()) {
        console.warn('用户已登录但无法获取用户名，尝试使用默认名称');
        return '登录用户'; // 提供一个默认值
      }
      
      // 6. 默认返回空字符串
      return "";
    },
    
    /** 查询债权转让列表 */
    getList() {
      this.loading = true;
      listInformation(this.queryParams).then(response => {
        this.informationList = response.rows;
        this.total = response.total;
        // 重置当天的编号映射，以便重新计算
        this.todayIdMap = null;
        this.maxSequence = null;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        debtorName: null,
        debtorIdCard: null,
        creditorName: null,
        creditorIdCard: null,
        amount: null,
        debtType: null,
        purchaseDate: null,
        currentStatus: null,
        followUpInfo: null,
        fileInfo: null,
        createById: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加债权转让信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInformation(id).then(response => {
        this.form = response.data;
        this.updateParsedFileList(); // 初始化已上传文件列表
        this.open = true;
        this.title = "修改债权转让信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            this.loading = true;
            updateInformation(this.form, { headers: { 'repeatSubmit': false } }).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
              this.loading = false;
              this.reset();
            }).catch(error => {
              console.error('修改操作失败:', error);
              this.$modal.msgError("修改失败: " + (error.message || JSON.stringify(error)));
              this.loading = false;
            });
          } else {
            // 获取当前登录用户名称
            this.loading = true;
            
            // 检查store中的用户信息
            console.log('Store中的用户state:', this.$store.state.user);
            console.log('Getters中的用户信息:', this.$store.getters.user);
            
            // 检查cookie中的用户名
            console.log('Cookie中的用户名:', Cookies.get("username"));
            
            // 使用辅助方法获取用户名称
            const userName = this.getCurrentUserName();
            if (userName) {
              this.form.createById = userName; // 设置为用户名称
              console.log('成功设置createById为用户名称:', this.form.createById);
            } else {
              console.warn('无法获取用户名称，createById将为空');
            }
            
            console.log('最终提交的表单数据:', JSON.stringify(this.form));
            addInformation(this.form, { headers: { 'repeatSubmit': false } }).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.loading = false;
              this.reset();
            }).catch(error => {
              console.error('提交表单失败:', error);
              this.$modal.msgError("提交失败: " + (error.message || (error.response && error.response.data ? error.response.data.msg : JSON.stringify(error))));
              this.loading = false;
            });
          }
        } else {
          this.$modal.msgError("表单验证失败，请检查填写的信息");
          this.loading = false;
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除债权转让编号为"' + ids + '"的数据项？').then(function() {
        return delInformation(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/information/export', {
        ...this.queryParams
      }, `information_${new Date().getTime()}.xlsx`)
    },
    /** 文件上传成功处理 */
    handleUploadSuccess(response, file, fileList) {
      if (response.code === 200) {
        // 如果已经有文件信息，追加新文件
        if (this.form.fileInfo) {
          this.form.fileInfo = this.form.fileInfo + ';' + response.data;
        } else {
          // 如果还没有文件信息，直接使用新文件
          this.form.fileInfo = response.data;
        }
        
        // 更新文件列表显示
        this.fileList = fileList;
        this.updateParsedFileList();
        this.$modal.msgSuccess(response.msg || "上传成功");
      } else {
        this.$modal.msgError(response.msg || "上传失败");
      }
    },
    /** 格式化文件名 */
    formatFileName(fullName) {
      if (!fullName) return '';
      // 移除时间戳和哈希值部分，只保留原始文件名
      const match = fullName.match(/^\d{14}_[a-f0-9]+_(.+)$/) || fullName.match(/^\d{14}_[a-f0-9]+\.(.+)$/);
      if (match && match[1]) {
        return match[1];
      }
      // 如果文件名包含|，说明是原始文件名|存储路径的格式
      if (fullName.includes('|')) {
        return fullName.split('|')[0];
      }
      // 如果没有匹配到特定格式，返回原始文件名
      return fullName;
    },
    updateParsedFileList() {
      if (!this.form.fileInfo) {
        this.parsedFileList = [];
        return;
      }
      
      console.log("Original fileInfo:", this.form.fileInfo);
      
      // 确保不会处理重复的文件
      const uniqueFiles = new Set(this.form.fileInfo.split(';'));
      this.parsedFileList = Array.from(uniqueFiles).map(fileInfo => {
        const parts = fileInfo.split('|');
        const originalName = parts[0] || fileInfo;
        const filePath = parts[1] || fileInfo;
        
        console.log("Parsed file:", { name: originalName, path: filePath, fullInfo: fileInfo });
        
        return {
          name: this.formatFileName(originalName), // Use formatFileName to clean up the display name
          path: fileInfo, // Keep the full fileInfo for download functionality
          fullInfo: fileInfo
        };
      });

      // 更新form中的fileInfo，确保没有重复项
      this.form.fileInfo = Array.from(uniqueFiles).join(';');
    },
    /** 文件删除处理 */
    handleFileDelete(index) {
      this.$modal.confirm('是否确认删除该文件？').then(() => {
        const files = this.form.fileInfo.split(';');
        files.splice(index, 1);
        this.form.fileInfo = files.join(';');
        this.updateParsedFileList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 文件移除处理 */
    handleFileRemove(file, fileList) {
      // 从parsedFileList中找到对应的文件信息
      const removedFile = this.parsedFileList.find(f => f.name === file.name);
      if (removedFile) {
        // 从fileInfo中移除该文件
        const files = this.form.fileInfo.split(';').filter(f => f !== removedFile.fullInfo);
        this.form.fileInfo = files.join(';');
        this.updateParsedFileList();
      }
      this.fileList = fileList;
    },
    /** 文件上传失败处理 */
    handleUploadError(error) {
      this.$modal.msgError("上传失败，请重试");
    },
    /** 文件上传前的处理 */
    handleBeforeUpload(file) {
      const isLt500M = file.size / 1024 / 1024 < 500;
      if (!isLt500M) {
        this.$modal.msgError('上传文件大小不能超过 500MB!');
        return false;
      }
      return true;
    },
    /** 下载单个文件 */
    handleDownload(file) {
      const baseUrl = process.env.VUE_APP_BASE_API;
      const token = getToken();
      
      // 打印完整的文件信息，帮助调试
      console.log("下载文件完整信息:", file);
      
      // 处理文件路径 - 解析从完整的fileInfo字符串
      let filePath = file.path;
      
      // 如果文件路径包含"|"，说明是以"原始文件名|存储路径"格式存储的
      if (filePath.includes('|')) {
        // 获取最后一个"|"后的内容，这才是真正的文件路径
        const parts = filePath.split('|');
        filePath = parts[parts.length - 1]; // 取最后一个部分
      }
      
      // 添加information目录前缀，如果path中不包含
      if (!filePath.startsWith('information/') && !filePath.includes('/information/')) {
        filePath = 'information/' + filePath;
      }
      
      // 检查是否是完整的URL，如果是，需要提取相对路径部分
      if (filePath.includes('http')) {
        const url = new URL(filePath);
        filePath = url.pathname.replace('/profile/', '');
      } 
      // 如果路径包含完整的profile路径，需要提取相对路径部分
      else if (filePath.includes('/profile/')) {
        // 从/profile/之后开始截取
        filePath = filePath.substring(filePath.indexOf('/profile/') + 9);
      } else if (filePath.startsWith('/profile/')) {
        filePath = filePath.substring(9);
      } else if (filePath.startsWith('/profile')) {
        filePath = filePath.substring(8);
      } else if (filePath.startsWith('profile/')) {
        filePath = filePath.substring(8);
      }
      
      const url = baseUrl + "/system/information/download-file?filePath=" + encodeURIComponent(filePath);
      
      console.log("Downloading file:", {
        name: file.name,
        originalPath: file.path,
        processedPath: filePath,
        fullUrl: url
      });
      
      const xhr = new XMLHttpRequest();
      xhr.open("GET", url, true);
      xhr.responseType = "blob";
      xhr.setRequestHeader("Authorization", "Bearer " + token);
      
      xhr.onload = () => {
        if (xhr.status === 200) {
          const blob = new Blob([xhr.response]);
          if (window.navigator.msSaveOrOpenBlob) {
            navigator.msSaveBlob(blob, file.name);
          } else {
            const url = window.URL.createObjectURL(blob);
            const link = document.createElement("a");
            link.href = url;
            link.setAttribute("download", file.name);
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            window.URL.revokeObjectURL(url);
          }
        } else {
          this.$modal.msgError("下载失败");
        }
      };
      
      xhr.onerror = () => {
        this.$modal.msgError("下载失败");
      };
      
      xhr.send();
    },
    formatCustomerId(id) {
      if (!id) return '';
      
      // 检查是否已经创建了编号映射
      if (!this.todayIdMap) {
        this.todayIdMap = {};
        
        // 对业务列表按照id从小到大排序
        const sortedList = [...this.informationList].sort((a, b) => {
          return (a.id || 0) - (b.id || 0);
        });
        
        // 为已有客户分配序号
        let sequence = 1;
        sortedList.forEach(item => {
          if (item && item.id) {
            // 使用创建日期
            const createDate = new Date(item.createTime);
            const year = createDate.getFullYear();
            const month = String(createDate.getMonth() + 1).padStart(2, '0');
            const day = String(createDate.getDate()).padStart(2, '0');
            const datePart = `${year}${month}${day}`;
            
            this.todayIdMap[item.id] = `ZQ${datePart}${String(sequence).padStart(2, '0')}`;
            sequence++;
            if (sequence > 99) sequence = 1; // 重置，避免超过两位数
          }
        });
        
        // 记录最大序号
        this.maxSequence = sequence - 1;
      }
      
      // 如果当前ID在映射中，直接返回
      if (this.todayIdMap[id]) {
        return this.todayIdMap[id];
      }
      
      // 否则为当前ID创建一个新的编号
      let newSequence = (this.maxSequence || 0) + 1;
      if (newSequence > 99) newSequence = 1;
      
      // 获取当前记录的创建日期
      const currentRecord = this.informationList.find(item => item.id === id);
      if (!currentRecord || !currentRecord.createTime) {
        return ''; // 如果没有找到记录或没有创建时间，返回空字符串
      }
      
      const createDate = new Date(currentRecord.createTime);
      const year = createDate.getFullYear();
      const month = String(createDate.getMonth() + 1).padStart(2, '0');
      const day = String(createDate.getDate()).padStart(2, '0');
      const datePart = `${year}${month}${day}`;
      
      // 创建新编号并保存
      const newId = `ZQ${datePart}${String(newSequence).padStart(2, '0')}`;
      this.todayIdMap[id] = newId;
      this.maxSequence = newSequence;
      
      return newId;
    },
  }
};
</script>

<style scoped>
.upload-demo {
  margin-bottom: 10px;
}

.el-upload__tip {
  line-height: 1.2;
  color: #909399;
  font-size: 12px;
}

.existing-files {
  margin-top: 10px;
  border: 1px solid #EBEEF5;
  border-radius: 4px;
  padding: 5px 10px;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #EBEEF5;
}

.file-item:last-child {
  border-bottom: none;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-actions {
  margin-left: 10px;
  white-space: nowrap;
}

.el-dialog .el-form-item__label {
  font-weight: bold;
}
</style>
